from appium.webdriver.common.mobileby import MobileBy

from APP_UI_TEST.contacts_podemo_enhance.base.base_page import BasePage
from APP_UI_TEST.contacts_podemo_enhance.page.member_management_page import MemberManagementPage
from APP_UI_TEST.contacts_podemo_enhance.page.search_member_page import SearchMemberPage


class MainPage(BasePage):
    """ 通讯录首页 """
    def go_to_team_tab(self):
        """点击下方tab“团队"""
        self.find_and_click(MobileBy.XPATH, "//*[@text='团队']")
        # print("团队：",self.driver.current_activity)
        return self

    def click_add_member(self):
        """ 点击添加成员..."""
        self.swipe_find_text_to_click("添加成员...")
        return MemberManagementPage(self.driver)

    def to_search_page(self):
        """ 点击右上角搜索图标,进到成员搜索页 """
        # 先找到公司名称，然后通过其相对位置，找到搜索图标。
        self.find_and_click(MobileBy.XPATH, "//*[@text='测试团队']/../../../following-sibling::*[1]")
        return SearchMemberPage(self.driver)





